cmake_minimum_required(VERSION 3.5)

project(fast_conv)

set(CMAKE_BUILD_TYPE "Debug")
# set(CMAKE_BUILD_TYPE "Release")

# cuda
find_package(CUDA REQUIRED)
message(STATUS "CUDA_INCLUDE_DIRS = ${CUDA_INCLUDE_DIRS}")
message(STATUS "CUDA_LIBRARIES = ${CUDA_LIBRARIES}")

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR})
message(STATUS "set CMAKE_CURRENT_SOURCE_DIR = ${CMAKE_CURRENT_SOURCE_DIR}")

# cudnn
set(CUDNN_LIBNAME "cudnn")
set(CUDNN_ROOT_DIR "/usr/lib/x86_64-linux-gnu")
message(STATUS "CUDNN_ROOT_DIR = ${CUDNN_ROOT_DIR}")
message(STATUS "CUDA_TOOLKIT_ROOT_DIR = ${CUDA_TOOLKIT_ROOT_DIR}")
find_library(CUDNN_LIBRARY ${CUDNN_LIBNAME}
    HINTS ${CUDNN_ROOT_DIR} ${CUDA_TOOLKIT_ROOT_DIR}
    PATH_SUFFIXES lib lib64 cuda/lib cuda/lib64 lib/x64)

set(CUDNN_LIBRARIES ${CUDNN_LIBRARY})
message(STATUS "CUDNN_LIBRARIES = ${CUDNN_LIBRARIES}")

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
add_subdirectory(src)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} test_conv ${CUDA_cublas_LIBRARY} ${CUDNN_LIBRARIES})

install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)